<template>
  <div>
    <page-list :x-uri="uri" :custom-components="custom" :doactions="doactions">
      <!-- 自定义tab -->
      <template v-slot:page-tabs>
        <edu-page-tabs :tab-list="xTabs" />
      </template>
    </page-list>

    <!-- 课程信息弹出层 -->
    <agent-video v-if="videoVisible" :course="currentVideo" :visible.sync="videoVisible" />
  </div>
</template>
<script>
import PageList from '@public/template/page_list.vue';
import Titile from './components/title.vue';
import CategoryTitle from '@/components/category-title';
import IsRecommend from './components/is_recommend.vue';
import Status from './components/status';
import EduPageTabs from '@public/template/tabs/page_tabs.vue';
import AgentVideo from './components/video.vue';

export default {
  components: {
    PageList,
    EduPageTabs,
    AgentVideo
  },
  inject: ['reload'],
  data() {
    return {
      uri: 'course/admin/agent/school',
      xTabs: [
        {
          title: '课程列表',
          uri: '/course/agent/school',
          meta: {
            permission: 'course.agent.school'
          }
        }
      ],
      custom: {
        title: Titile,
        cates: CategoryTitle,
        is_recommend: IsRecommend,
        status: Status
      },
      datas: [],
      videoVisible: false, // 弹出层
      currentVideo: {
        vid: 0,
        type: 1,
        aid: 0
      }, // 当前课程信息
      doactions: [
        {
          title: '学员',
          meta: { permission: 'course.agent.school.user' },
          callback: this.user
        },
        {
          title: '课程信息',
          meta: { permission: 'course.agent.school' },
          callback: this.videoinfo
        }
      ]
    };
  },
  methods: {
    // 课程信息
    videoinfo({ row }) {
      this.currentVideo.aid = row.id;
      this.currentVideo.vid = row.course_id;
      this.currentVideo.type = row.course_type;
      this.videoVisible = true;
    },
    user: function({ row }) {
      this.$router.push({ path: '/course/agent/school/' + row.course_id + '/user' });
    }
  }
};
</script>
